package com.power.project.model;


import com.power.common.domain.BaseModel;
import com.power.project.model.bo.UserSaveBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
*  实体类
*/

@Entity
@ApiModel(value="")
@Data
@Table(name="Ww_user")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Ww_user.Ww_userPK.class) 用于复合组件
public class Ww_user extends BaseModel implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    @ApiModelProperty(value = "")
    private Integer id;

    @Column(nullable = false)
    @ApiModelProperty(value = "用户id")
    private String userid;

    @ApiModelProperty(value = "用户名称")
    private String name;

    @ApiModelProperty(value = "用户头像")
    private String avatar;

    @ApiModelProperty(value = "用户手机号")
    private String mobile;

    @ApiModelProperty(value = "主部门id")
    private String maindepartment;

    @ApiModelProperty(value = "租户id")
    private String tenantid;

    @Transient
    @ApiModelProperty(value = "管理员标识（3200:超级 ；3201普通）")
    private Integer owner;

    public Ww_user(UserSaveBO saveBO) {
        setSaveBO(saveBO);
    }


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("userid", this.getUserid());
        map.put("name", this.getName());
        map.put("avatar", this.getAvatar());
        map.put("mobile", this.getMobile());
        map.put("maindepartment", this.getMaindepartment());
        map.put("tenantid", this.getTenantid());
        return map;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (Integer) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Ww_userPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (Integer)key;

        //Ww_userPK pk = (Ww_userPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

    public void setSaveBO(UserSaveBO saveBO) {
        this.userid = saveBO.getUserId();
        this.avatar = saveBO.getAvatar();
        this.name = saveBO.getName();
        this.mobile = saveBO.getMobile();
        this.maindepartment = saveBO.getMainDepartId();
        this.tenantid = saveBO.getTenantId();
    }
}